#define _CRT_SECURE_NO_WARNINGS 1
#include"Queue.h"
void Create(Queue* Q, int mSize)
{
	Q->maxSize = mSize;
	Q->element = (ElemType*)malloc(sizeof(ElemType) * mSize);
	Q->front = Q->rear = 0;
}
void Destroy(Queue* Q)
{
	free(Q->element);
	Q->maxSize = -1;
	Q->front = Q->rear = -1;
}
bool IsEmpty(Queue* Q)
{
	return Q->front == Q->rear;
}
bool IsFull(Queue* Q)
{
	return (Q->rear + 1) % Q->maxSize == Q->front;
}
bool Front(Queue* Q, ElemType* x)
{
	if (IsEmpty(Q))
		return false;
	*x = Q->element[(Q->front + 1) % Q->maxSize];
	return true;
}
bool EnQueue(Queue* Q, ElemType x)
{
	if (IsFull(Q))
		return false;
	Q->rear = (Q->rear + 1) % Q->maxSize;
	Q->element[Q->rear] = x;
	return true;
}
bool DeQueue(Queue* Q)
{
	if (IsEmpty(Q))
		return false;
	Q->front = (Q->front + 1) % Q->maxSize;
	return true;
}